/* Theme Variables */
:root[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent-primary: #3b82f6;
    --accent-secondary: #60a5fa;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --hover-bg: #f1f5f9;
    --stat-box-bg: #f8fafc;
    --activity-bg: #f8fafc;
    --text-muted: #64748b;
    --stats-box-highlight: #f0f9ff;
    --token-usage-bg: #eff6ff;
    --stats-border: #e2e8f0;
}

:root[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #e2e8f0;
    --accent-primary: #60a5fa;
    --accent-secondary: #93c5fd;
    --border-color: #334155;
    --card-bg: #1e293b;
    --sidebar-bg: #1e293b;
    --hover-bg: #334155;
    --stat-box-bg: #1e293b;
    --activity-bg: #1e293b;
    --text-muted: #cbd5e1;
    --stats-box-highlight: #172554;
    --token-usage-bg: #1e3a8a;
    --stats-border: #1e40af;
}

/* Base Styles */
body {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    position: relative;
}

/* Layout */
.layout-container {
    display: flex;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-primary);
}

.sidebar-nav {
    padding: 1.5rem 0;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background: var(--hover-bg);
    color: var(--accent-primary);
}

.sidebar-link.active {
    background: var(--hover-bg);
    color: var(--accent-primary);
    border-right: 3px solid var(--accent-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 0 2rem 2rem;
    overflow-y: auto;
    width: calc(100% - 260px);
}

.content-wrapper {
    width: 100%;
    padding-right: 2rem;
}

.content-header {
    margin-bottom: 2rem;
}

.content-title {
    font-size: 1.875rem;
    font-weight: bold;
    color: var(--text-primary);
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
}

.col-span-2 {
    grid-column: span 2;
}

.material-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
                0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.material-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
                0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.card-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Stats Box */
.stat-box {
    background: var(--stat-box-bg);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--stats-border);
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.stat-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    background: var(--hover-bg);
}

/* Improved Token Usage Styling */
.bg-blue-50 {
    background-color: var(--token-usage-bg) !important;
    color: var(--text-primary);
    border: 1px solid var(--stats-border);
}

.bg-gray-50 {
    background-color: var(--stat-box-bg) !important;
    color: var(--text-primary);
    border: 1px solid var(--stats-border);
}

/* Text colors for stats */
.text-gray-600 {
    color: var(--text-muted) !important;
}

.font-semibold {
    color: var(--text-primary);
}

.text-xl {
    color: var(--text-primary);
}

/* Stats legend improvements */
.stats-legend .stat-item {
    padding: 0.75rem;
    border-radius: 6px;
    background: var(--stat-box-bg);
    margin-bottom: 0.5rem;
}

.stat-item span {
    color: var(--text-primary);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    background: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
                0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    overflow: hidden;
    border: 1px solid var(--border-color);
    z-index: 51;
}

.modal.show .modal-container {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.modal-content {
    padding: 1.25rem;
    overflow-y: auto;
    max-height: calc(80vh - 70px);
    background: var(--card-bg);
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1000;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--hover-bg);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .layout-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        width: 100%;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .col-span-2 {
        grid-column: span 1;
    }

    .modal-container {
        width: 95%;
        margin: 1rem;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-secondary);
    border-radius: 4px;
}

/* Base Styles */
body {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Modern Input Styles */
.modern-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    background-color: var(--input-bg);
    color: var(--input-text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modern-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Form Group Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
}

.help-text {
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Password Input Container */
.password-input {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input .modern-input {
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
}

.password-toggle:hover {
    color: var(--accent-primary);
}

/* Material Button */
.material-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.material-button:hover {
    background-color: var(--button-hover);
    transform: translateY(-1px);
}

.material-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Tag Input Styles */
.tag-input-container {
    display: flex;
    gap: 0.5rem;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.modern-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background-color: var(--accent-secondary);
    color: var(--button-text);
    border-radius: 9999px;
    font-size: 0.875rem;
}

.modern-tag button {
    background: none;
    border: none;
    color: var(--button-text);
    cursor: pointer;
    padding: 0.125rem;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.modern-tag button:hover {
    opacity: 1;
}

/* Prompt Container */
.prompt-container {
    position: relative;
}

.example-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem;
    font-size: 0.875rem;
}

/* Card Styles */
.material-card {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.material-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
                0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Provider Settings */
.provider-settings {
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    margin-top: 1rem;
}

/* Tooltip Styles */
.tippy-box[data-theme~='custom'] {
    background-color: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.tippy-box[data-theme~='custom'] .tippy-content {
    padding: 1rem;
}

.tippy-box[data-theme~='custom'] code {
    background-color: var(--bg-secondary);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: monospace;
}

/* Layout Styles */
.layout-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    overflow-y: auto;
}

.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
}

.content-header {
    margin-bottom: 2rem;
}

.content-title {
    font-size: 1.875rem;
    font-weight: bold;
    color: var(--text-primary);
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1000;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--hover-bg);
}

/* Submit Button Styling */
.submit-btn {
    background-color: var(--accent-primary);
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.submit-btn:hover {
    background-color: var(--button-hover);
    transform: translateY(-1px);
}

/* Divider Styling */
hr {
    border: 0;
    height: 1px;
    background-color: var(--border-color);
    margin: 1.5rem 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .layout-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        width: 100%;
    }

    .tag-input-container {
        flex-direction: column;
    }

    .theme-toggle {
        top: 0.75rem;
        right: 0.75rem;
    }
}

/* Animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* Helper Classes */
.hidden {
    display: none !important;
}

/* Transitions */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Help Button */
.help-btn {
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

/* Example Button */
.example-btn {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    min-width: 120px;
}

.example-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

/* Tag Animation */
@keyframes slideOut {
    0% { 
        transform: scale(1); 
        opacity: 1; 
    }
    100% { 
        transform: scale(0.9); 
        opacity: 0; 
    }
}

.slide-out {
    animation: slideOut 0.2s ease-out forwards;
}

/* Provider Settings */
.provider-settings {
    display: none;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.provider-settings.active {
    display: block;
}

/* Input Validation States */
.modern-input.error {
    border-color: var(--error-text);
    background-color: var(--error-bg);
}

.modern-input.success {
    border-color: var(--success-text);
    background-color: var(--success-bg);
}